package com.qf.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 天--道--酬--勤
 *
 * @author LiangGaoQiang
 * @ClassName Knife4jConfiguration
 * @Date: 2025/4/9 19:27
 * @Description: 描述
 *
 */

@Configuration // 开启配置
@EnableSwagger2 // 启动Swagger2
public class Knife4jConfiguration {
    // 默认访问地址:http://localhost:端口号/doc.html
    @Bean
    public Docket defaultApi2() {
        String groupName = "1.0版本";
        Docket docket = new Docket(DocumentationType.OAS_30)
                // 是否启用Swagger
                .enable(true)
                .apiInfo(new ApiInfoBuilder()
                        .title("这是学生信息管理系统API接口文档")
                        .description("本项目使用springboot+SSM+MySql+Swagger2构建的学生信息管理系统API接口文档")
                        .termsOfServiceUrl("localhost:8080")
                        .contact(new Contact("lgq", null, "1204759906@qq.com"))
                        .version("1.0")
                        .build())
                //分组名称
                .groupName(groupName)
                .select()
                // 这里指定Controller扫描包路径,没有加注解的接口方法也会生成接口文档
                .apis(RequestHandlerSelectors.basePackage("com.qf.controller"))

                // 这里指定只有加了注解的才会生成接口文档
                //.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
}